---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/MilitaryCareer/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 22:01:10

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/MilitaryCareer";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/MilitaryCareer

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Wednesday, December 3, 2014                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. *********************************;
. **      Peace to War            *;
. *********************************;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/MilitaryCareer/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0
>                 prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 diff_hat01 diff_lo01 diff_hi01
>                 prob_hat02 lo02 hi02 prob_hat12 lo12 hi12 diff_hat02 diff_lo02 diff_hi02
>                 delta_hat delta_lo delta_hi
>                 delta_hat1 delta_lo1 delta_hi1 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3. scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_NonCombat = 1;
  9. scalar h_Combat = 1;
 10.  scalar h_Parliament = 0;
 11. scalar h_CivilWar = 0;
 12. scalar h_GDPpc =  12589.35;
 13. scalar h_Growth = 3.453132;
 14. scalar h_MajorPower = 0;
 15. scalar h_Borders = 2;
 16. scalar h_Mobilization =  -.0008714 ;
 17. scalar h_Time = 5;
 18.  scalar h_NonCareer = 1;
 19. scalar h_Career = 1;
 20. scalar h_Rivalry = 0;
 21. scalar h_Female = 0;
 22. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Civilian
>     + MG_b3*(h_Accountable*h_Civilian)
>     + MG_b4*h_Civilian
>     + MG_b5*(h_Accountable*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 23. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*h_Civilian
>     + MG_b3*(h_LameDuck*h_Civilian)
>     + MG_b4*h_Civilian
>     + MG_b5*(h_LameDuck*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 24.  gen prob0=1/(1+exp(-x_betahat0));
 25. gen prob1=1/(1+exp(-x_betahat1));
 26.  gen diff0=prob1-prob0 ;
 27. egen probhat0=mean(prob0) ;
 28. egen probhat1=mean(prob1) ;
 29. egen diffhat0=mean(diff0) ;
 30. generate x_betahat01 =  MG_b1*h_Accountable
>     + MG_b2*h_Career
>     + MG_b3*(h_Accountable*h_Career)
>     + MG_b4*h_Civilian
>     + MG_b5*(h_Accountable*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 31.  generate x_betahat11 =   MG_b1* h_LameDuck
>     + MG_b2*h_Career
>     + MG_b3*(h_LameDuck*h_Career)
>     + MG_b4*h_Civilian
>     + MG_b5*(h_LameDuck*h_Civilian)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 32.   gen prob01=1/(1+exp(-x_betahat01));
 33. gen prob11=1/(1+exp(-x_betahat11));
 34. gen diff01=prob11-prob01 ;
 35. egen probhat01=mean(prob01) ;
 36. egen probhat11=mean(prob11) ;
 37. egen diffhat01=mean(diff01) ;
 38. generate x_betahat02 =   MG_b1*h_Accountable
>     + MG_b2*h_Civilian
>     + MG_b3*(h_Accountable*h_Civilian)
>     + MG_b4*h_NonCareer
>     + MG_b5*(h_Accountable*h_NonCareer)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 39.  generate x_betahat12 =   MG_b1* h_LameDuck
>     + MG_b2*h_Civilian
>     + MG_b3*(h_LameDuck*h_Civilian)
>     + MG_b4*h_NonCareer
>     + MG_b5*(h_LameDuck*h_NonCareer)
>     + MG_b6*h_Rivalry
>     + MG_b7*h_Borders
>     + MG_b8*h_Parliament
>     + MG_b9*h_Female
>     + MG_b10*h_Time
>     + MG_b11*(h_Time^2)
>     + MG_b12*(h_Time^3)
>     + MG_b13*h_Constant;
 40.   gen prob02=1/(1+exp(-x_betahat02));
 41. gen prob12=1/(1+exp(-x_betahat12));
 42. gen diff02=prob12-prob02 ;
 43. egen probhat02=mean(prob02) ;
 44. egen probhat12=mean(prob12) ;
 45. egen diffhat02=mean(diff02) ;
 46.  gen delta=diff01-diff0;
 47. gen delta1=diff02-diff0;
 48.  egen deltahat=mean(delta);
 49. egen deltahat1=mean(delta1);
 50. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat0 diff_lo0 diff_hi0
>          prob_hat01 lo01 hi01 prob_hat11 lo11 hi11 diff_hat01 diff_lo01 diff_hi01
>          prob_hat02 lo02 hi02 prob_hat12 lo12 hi12 diff_hat02 diff_lo02 diff_hi02
>          delta_hat delta_lo delta_hi
>          delta_hat1 delta_lo1 delta_hi1;
 51.     _pctile prob0, p(2.5,97.5) ;
 52.     scalar `lo0'=r(r1) ;
 53.     scalar `hi0'=r(r2) ;
 54.     _pctile prob1, p(2.5,97.5) ;
 55.     scalar `lo1'=r(r1) ;
 56.     scalar `hi1'=r(r2) ;
 57.     _pctile diff0, p(2.5,97.5) ;
 58.     scalar `diff_lo0'= r(r1) ;
 59.     scalar `diff_hi0'=r(r2) ;
 60.     scalar `prob_hat0'=probhat0 ;
 61.     scalar `prob_hat1'=probhat1 ;
 62.     scalar `diff_hat0'=diffhat0 ;
 63.        _pctile prob01, p(2.5,97.5) ;
 64.     scalar `lo01'=r(r1) ;
 65.     scalar `hi01'=r(r2) ;
 66.     _pctile prob11, p(2.5,97.5) ;
 67.     scalar `lo11'=r(r1) ;
 68.     scalar `hi11'=r(r2) ;
 69.     _pctile diff01, p(2.5,97.5) ;
 70.     scalar `diff_lo01'= r(r1) ;
 71.     scalar `diff_hi01'=r(r2) ;
 72.     scalar `prob_hat01'=probhat01 ;
 73.     scalar `prob_hat11'=probhat11 ;
 74.     scalar `diff_hat01'=diffhat01 ;
 75.        _pctile prob02, p(2.5,97.5) ;
 76.     scalar `lo02'=r(r1) ;
 77.     scalar `hi02'=r(r2) ;
 78.     _pctile prob12, p(2.5,97.5) ;
 79.     scalar `lo12'=r(r1) ;
 80.     scalar `hi12'=r(r2) ;
 81.     _pctile diff02, p(2.5,97.5) ;
 82.     scalar `diff_lo02'= r(r1) ;
 83.     scalar `diff_hi02'=r(r2) ;
 84.     scalar `prob_hat02'=probhat02 ;
 85.     scalar `prob_hat12'=probhat12 ;
 86.     scalar `diff_hat02'=diffhat02 ;
 87.      _pctile delta, p(2.5,97.5) ;
 88.     scalar `delta_lo'= r(r1) ;
 89.     scalar `delta_hi'=r(r2) ;
 90.      _pctile delta1, p(2.5,97.5) ;
 91.     scalar `delta_lo1'= r(r1) ;
 92.     scalar `delta_hi1'=r(r2) ;
 93.      scalar `delta_hat'=deltahat;
 94.     scalar `delta_hat1'=deltahat1;
 95.     post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat0') (`diff_lo0') (`diff_hi0')
>                 (`prob_hat01') (`lo01') (`hi01') (`prob_hat11') (`lo11') (`hi11') (`diff_hat01') (`diff_lo01') (`diff_hi0
> 1')
>                 (`prob_hat02') (`lo02') (`hi02') (`prob_hat12') (`lo12') (`hi12') (`diff_hat02') (`diff_lo02') (`diff_hi0
> 2')
>                 (`delta_hat') (`delta_lo') (`delta_hi')
>                 (`delta_hat1') (`delta_lo1') (`delta_hi1')
> 
>     ;
 96.     } ;
 97.     drop    x_betahat0 x_betahat1 prob0 prob1 diff0 probhat0 probhat1 diffhat0
>             x_betahat01 x_betahat11 prob01 prob11 diff01 probhat01 probhat11 diffhat01
>             x_betahat02 x_betahat12 prob02 prob12 diff02 probhat02 probhat12 diffhat02
>             delta deltahat
>             delta1 deltahat1;
 98.     local a=`a'+ .1 ;
 99.     display "." _c ;
100.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .0512284           .   .0512284   .0512284
         lo0 |         1    .0346151           .   .0346151   .0346151
         hi0 |         1    .0731537           .   .0731537   .0731537
   prob_hat1 |         1     .026341           .    .026341    .026341
         lo1 |         1    .0163575           .   .0163575   .0163575
-------------+--------------------------------------------------------
         hi1 |         1    .0403981           .   .0403981   .0403981
   diff_hat0 |         1   -.0248873           .  -.0248873  -.0248873
    diff_lo0 |         1   -.0448277           .  -.0448277  -.0448277
    diff_hi0 |         1   -.0076836           .  -.0076836  -.0076836
  prob_hat01 |         1    .0661742           .   .0661742   .0661742
-------------+--------------------------------------------------------
        lo01 |         1    .0280615           .   .0280615   .0280615
        hi01 |         1    .1315094           .   .1315094   .1315094
  prob_hat11 |         1    .0600089           .   .0600089   .0600089
        lo11 |         1    .0139396           .   .0139396   .0139396
        hi11 |         1    .1633039           .   .1633039   .1633039
-------------+--------------------------------------------------------
  diff_hat01 |         1   -.0061653           .  -.0061653  -.0061653
   diff_lo01 |         1   -.0862191           .  -.0862191  -.0862191
   diff_hi01 |         1    .1003199           .   .1003199   .1003199
  prob_hat02 |         1    .0764533           .   .0764533   .0764533
        lo02 |         1    .0495089           .   .0495089   .0495089
-------------+--------------------------------------------------------
        hi02 |         1    .1110602           .   .1110602   .1110602
  prob_hat12 |         1    .0583961           .   .0583961   .0583961
        lo12 |         1      .01638           .     .01638     .01638
        hi12 |         1    .1469719           .   .1469719   .1469719
  diff_hat02 |         1   -.0180571           .  -.0180571  -.0180571
-------------+--------------------------------------------------------
   diff_lo02 |         1   -.0716393           .  -.0716393  -.0716393
   diff_hi02 |         1    .0694084           .   .0694084   .0694084
   delta_hat |         1     .018722           .    .018722    .018722
    delta_lo |         1   -.0601296           .  -.0601296  -.0601296
    delta_hi |         1    .1256285           .   .1256285   .1256285
-------------+--------------------------------------------------------
  delta_hat1 |         1    .0068302           .   .0068302   .0068302
   delta_lo1 |         1   -.0455205           .  -.0455205  -.0455205
   delta_hi1 |         1    .0966915           .   .0966915   .0966915

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. 
end of do-file

. clear all

. do "/var/folders/pp/9dcr80c13r9_24bby6f4sjrh0000gn/T//SD01417.000000"

. # delimit ;
delimiter now ;
. clear;

. *version 13;
. set matsize 400;

. set more off;

. log using "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/Primary/PredictedValues.log", replace;
log file already open
r(604);

end of do-file

r(604);

. log close
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Conditional/MilitaryCareer/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 22:03:31
---------------------------------------------------------------------------------------------------------------------------
